package com.dime.volumnwidget;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    TextView tv_volumn_number;
    Button btn_mute, btn_down, btn_up;

    VolumnUtils volumnUtils;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        volumnUtils = new VolumnUtils(this);

        tv_volumn_number = findViewById(R.id.tv_volumn_number);
        btn_mute = findViewById(R.id.btn_up);
        btn_down = findViewById(R.id.btn_down);
        btn_up = findViewById(R.id.btn_up);

        tv_volumn_number.setText(volumnUtils.getCurrentVolumn() + "");

        btn_mute.setOnClickListener(v -> {
            tv_volumn_number.setText(volumnUtils.volumnMute() + "");
        });

        btn_up.setOnClickListener(v -> {
            tv_volumn_number.setText(volumnUtils.volumnUp() + "");
        });

        btn_down.setOnClickListener(v -> {
            tv_volumn_number.setText(volumnUtils.volumnDown() + "");
        });

        tv_volumn_number.setOnClickListener(v -> {
            Intent systemSoundSettingIntent = new Intent().setAction(Settings.ACTION_SOUND_SETTINGS);
            startActivity(systemSoundSettingIntent);
        });


    }
}